package com.star.mall.mq.producer.impl;

import com.star.mall.mq.producer.JmsProducer;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("rabbitmq")
@ConditionalOnProperty(
        prefix = "jms",
        name = {"mode"},
        havingValue = "rabbitmq",
        matchIfMissing = true
)
public class RabbitMQProducer implements JmsProducer {

    @Resource
    RabbitTemplate rabbitTemplate;

    @Override
    public void send2Queue(Object object, String queueName) {
        rabbitTemplate.convertAndSend(queueName, object);
    }
}
